#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 1010;
char s[N];
int n;
int f[N][N];
int main()
{
    cin >> s;
    n = strlen(s);
    for (int len = 1; len <= n; len++)
    {
        for (int l = 0; l + len - 1 <= n; l++)
        {
            int r = l + len - 1;
            if (len == 1)
                f[l][r] = 1;
            else
            {
                if (s[l] == s[r])
                    f[l][r] += f[l + 1][r - 1] + 2;
                if (f[l][r] < f[l + 1][r])
                    f[l][r] = f[l + 1][r];
                if (f[l][r] < f[l][r - 1])
                    f[l][r] = f[l][r - 1];
            }
        }
    }
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<n;j++)
    //         cout<<f[i][j]<<" ";
    //     cout<<endl;
    // }
    cout << n - f[0][n - 1] << endl;
    return 0;
}